<template>
  <div class="mod-config">
    <table-view ref="view"
                :searchAttrs="searchAttrs"
                :primaryKey="primaryKey"
                :listApiName="listApiName"
                :deleteApiName="deleteApiName"
                :saveAuthName="saveAuthName"
                :deleteAuthName="deleteAuthName"
                :templateDownloadApiName="templateDownloadApiName"
                :importApiName="importApiName"
                :exportApiName="exportApiName"
                :showAttrs="showAttrs"
    >
    </table-view>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <productinfo-add-or-update v-if="productInfoVisible" ref="productInfo"></productinfo-add-or-update>

  </div>
</template>

<script>
import AddOrUpdate from './modelinfo-add-or-update'
import tableView from '@/components/tableView'
import basicMixins from '@/utils/commonViewMixins'
import ProductinfoAddOrUpdate from '@/views/modules/product/productinfo-add-or-update'

export default {
  mixins: [basicMixins],
  data() {
    return {
      searchAttrs: {
        modelNo: {
          label: '模具编号',
          placeholder: '请输入模具编号'
        },
        productNo: {
          label: '产品名称',
          placeholder: '请输入产品名称',
      },
        location: {
          label: '位置',
          placeholder: '请输入位置',
        },
      },
      productInfoVisible: false,
      primaryKey: 'id',
      listApiName: 'modelApi/listModelInfo',
      deleteApiName: 'modelApi/deleteModelInfo',
      exportApiName: 'modelApi/exportModelInfoList',
      saveAuthName: 'model:modelinfo:save',
      deleteAuthName: 'model:modelinfo:delete',
      templateDownloadApiName: 'modelApi/templateDownloadModelInfo',
      importApiName: 'modelApi/importModelInfo',
      showAttrs: {
        location: {label: '模具所在地', width:120},
        modelNo: {label: '产品名称'},
        modelDrawingId: {label: '图纸', showKey: 'productNo', type: 'file', width: 140},
        // modelCategoryName: {label: '模具类别'},
        productWeight: {label: '克重量（g）'},
        productVolume: {label: '容量'},
        successMo: {label: '成模'},
        primaryMo: {label: '初模'},
        menTou: {label: '闷头'},
        louDou: {label: '漏斗'},
        kouZi: {label: '口子'},
        xinZi: {label: '芯子'},
        qiTou: {label: '气头'},
        qianPian: {label: '钳片'},
        lengQue: {label: '冷却'},
        generateKouMo: {label: '通用口模', width:100},
        modelFactory: {label: '模具厂'},
        remark: {label: '备注'},

/*        storageStatus: {
          label: '库存状态',
          type: 'radio',
          items: [
            {value: 0, text: '不在库', tagType: 'danger'},
            {value: 1, text: '在库'}
          ]
        },*/
        status: {
          label: '状态',
          type: 'radio',
          items: [
            {value: 0, text: '禁用', tagType: 'danger'},
            {value: 1, text: '正常'}
          ]
        }
      }
    }
  },
  methods: {
    openProductInfoDialog(cb) {
      this.productInfoVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.productInfo)) {
          this.$refs.productInfo.init(null, {status: 1}, cb)
        }
      })
    },
  },
  components: {
    AddOrUpdate,
    ProductinfoAddOrUpdate,
    tableView
  }
}
</script>
